/**
 * JavaScript core library.
 * @author shenw
 */

/**
 * Build package.
 * @param {String} path
 */
function pack(path){
    var piece = path.split(/\./);
    if (piece.length > 0) {
        var pack = this;
        for (var i = 0; i < piece.length; i++) {
            if (!pack[piece[i]]) {
                pack[piece[i]] = beget(Function);
            }
            pack = pack[piece[i]];
        }
    }
	return pack;
};
/**
 * Add method to function.
 * @param {String} name
 * @param {Function} func
 */
Function.prototype.method = function(name, func){
    if (!this.prototype[name]) {
        this.prototype[name] = func;
    }
    return this;
}
/**
 * Inherit object and return instance.
 * @param {Object} parent
 * @return {Object} child
 */
Object.method('beget', function(parent){
    var F = function(){};
    F.prototype = parent;
    return new F();
});
